import React, {useEffect, useState} from 'react';
import {View,} from '@tarojs/components';


import styles from './index.module.scss';
import {Tabs} from "@taroify/core";
import CouponItem from "@/mall/pages/coupons/CouponItem";

const Index: React.FC = () => {
    const [value, setValue] = useState(0)
    const [couponList, setCouponssList] = useState<any>([])

    useEffect(() => {
        load();
    }, []);

    const load = async () => {
        setCouponssList([
            {
                amount: '25',
                condition: '满300元可用',
                title: '家电满减券 - 5',
                time: '2023.01.01-2024.01.01',
            },
            {
                amount: '10',
                condition: '满100元可用',
                title: '零食满减券 - 3',
                time: '2023.06.18-2023.12.31',
            },
            {
                amount: '50',
                condition: '满500元可用',
                title: '服饰满减券 - 1',
                time: '2023.10.01-2024.03.31',
            },
            {
                amount: '15',
                condition: '满150元可用',
                title: '美妆满减券 - 4',
                time: '2023.11.11-2023.12.11',
            },
            {
                amount: '30',
                condition: '满250元可用',
                title: '数码满减券 - 6',
                time: '2024.02.01-2024.05.01',
            }
        ])
    }


    return (
        <View className={styles.page}>
            <Tabs sticky swipeable value={value} onChange={setValue}>
                <Tabs.TabPane title="可使用"></Tabs.TabPane>
                <Tabs.TabPane title="已使用"></Tabs.TabPane>
                <Tabs.TabPane title="已失效"></Tabs.TabPane>
            </Tabs>
            <View className={styles.page_body}>

                {couponList.map((item, index) => (
                    <View className={styles.page_body_item} key={index}>
                        <CouponItem data={item}></CouponItem>
                    </View>
                ))}
            </View>

        </View>
    );
};

export default Index;
